package com.szqhyxj.youxiangju.sys.components;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;

import com.szqhyxj.youxiangju.R;


/**
 * Created by xzh on 2017/4/28.
 */

public abstract class BaseDialog implements View.OnClickListener {
    public Dialog dialog;
    public Window window;

    public BaseDialog(Context context) {
        dialog = new Dialog(context, R.style.Transport_Dialog);
        window = dialog.getWindow();
        setWindowAnimation(R.style.dialog_bottom_top);

        dialog.setContentView(initDialogView(context));
        dialog.setCanceledOnTouchOutside(true);
    }





    protected abstract View initDialogView(Context context);


    public void setWindowAnimation(int resid) {
        window.setWindowAnimations(resid);
    }

    public void setGravity(int gravity) {
        window.setGravity(gravity);
    }

    public void show() {
        if (dialog != null && !dialog.isShowing()) {
            dialog.show();
        }
    }

    public void dismiss() {
        if (dialog != null && dialog.isShowing())
            dialog.dismiss();
    }

    public void cancel() {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
    }

    @Override
    public void onClick(View v) {

    }
}
